package com.qfedu.common.utils;

import com.qfedu.common.constant.CommonConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 2024/11/12 15:23
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class R {

    private int code;

    private String msg;

    private Object data;

    // 成功响应
    @SuppressWarnings("unused")
    public static R ok() {
        return new R(CommonConstant.SUCCESS, "成功", null);
    }

    @SuppressWarnings("unused")
    public static R ok(String msg) {
        return new R(CommonConstant.SUCCESS, msg, null);
    }


    @SuppressWarnings("unused")
    public static R ok(Object data) {
        return new R(CommonConstant.SUCCESS, "成功", data);
    }

    @SuppressWarnings("unused")
    public static R ok(int code, String msg) {
        return new R(code, msg, null);
    }

    @SuppressWarnings("unused")
    public static R ok(String msg, Object data) {
        return new R(CommonConstant.SUCCESS, msg, data);
    }


    @SuppressWarnings("unused")
    public static R ok(int code, Object data) {
        return new R(CommonConstant.SUCCESS, "成功", data);
    }

    @SuppressWarnings("unused")
    public static R ok(int code, String msg, Object data) {
        return new R(code, msg, data);
    }

    // 失败响应
    @SuppressWarnings("unused")
    public static R fail() {
        return new R(CommonConstant.ERROR, "失败", null);
    }

    @SuppressWarnings("unused")
    public static R fail(Object data) {
        return new R(CommonConstant.ERROR, "失败", data);
    }

    @SuppressWarnings("unused")
    public static R fail(int code, String msg) {
        return new R(code, msg, null);
    }

    @SuppressWarnings("unused")
    public static R fail(String msg, Object data) {
        return new R(CommonConstant.ERROR, msg, data);
    }

    @SuppressWarnings("unused")
    public static R fail(int code, Object data) {
        return new R(CommonConstant.SUCCESS, "失败", data);
    }

    @SuppressWarnings("unused")
    public static R fail(int code, String msg, Object data) {
        return new R(code, msg, data);
    }
}
